home *** CD-ROM | disk | FTP | other *** search
- Path: pegasus.montclair.edu!harmon
- From: harmon@pegasus.montclair.edu (Derek Harmon)
- Newsgroups: comp.lang.c
- Subject: Re: string and NULL :question
- Date: 12 Feb 1996 17:17:45 -0500
- Organization: Montclair State University
- Message-ID: <harmon.824162937@pegasus.montclair.edu>
- References: <zakrzews.824018783@pegasus.montclair.edu>
- NNTP-Posting-Host: pegasus.montclair.edu
- X-Newsreader: NN version 6.5.0 #68 (NOV)
-
- zakrzews@pegasus.montclair.edu (Tomas Zakrzewski) writes:
-
- >Is it save to use a string library and stdio library with strings that are
- >no terminated by NULL charater. If is not, which function may not work correctly
- >and what would happen with non termianded string if a function is applied to
- >that string.
-
- Short answer, No. In C convention, all "strings" are null-terminated.
- This is a sort of formal protocol that all arrays of characters, etc, must
- adhere to for the string functions to operate properly on them. The specs
- for the string functions will likely explain that any (char *)'s they expect
- as arguments must be Null-terminared (with an ASCII '\0', such a string con-
- vention is also sometimes referred to as ASCIIZ strings). If they are not
- Null-terminated, the best you can expect is they will continue their proces-
- sing past the end of your string until they do find a null character, '\0'.
-
- The ASCIIZ string convention of C is different from other languages like
- Pascal, where a leading byte contains the string length and the string follows.
- Conversion is generally straightforward, and must be performed before any
- calls you may make to libraries written in languages with other conventions
- for handling strings.
- -- Stone
- --
- # Derek Harmon (aka Stonelight) harmon@pegasus.montclair.edu
- # - Computer Science Undergrad, Montclair State University, NJ
- # - My views are my own, nobody else is this creative. 3;)>
- ... Eat prune yogurt for that get-up-and-go feeling.
-